//
//  RootViewController.m
//  UI11home
//
//  Created by dllo on 15/11/8.
//  Copyright (c) 2015年 liyinkai. All rights reserved.
//

#import "RootViewController.h"
#import "NewTableViewCell.h"
#import "TwoTableViewCell.h"
@interface RootViewController ()
@property (nonatomic, retain) BigModel *bigmodel;
@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSDictionary *dic = [[NSDictionary alloc] initWithContentsOfFile:@"/Users/apple/Desktop/homework/ui11/UI11homework/UI11home/UI11home/YiChe.plist"];
//    把字典变成model
    _bigmodel = [[BigModel alloc] init];
    [_bigmodel setValuesForKeysWithDictionary:dic];
//    ZhongModel *a = _bigmodel.datasouce;
//    NSArray *b = a.listq;
//    XiaoModel *x = b[0];
//    NSLog(@"%@", x.title);
    
    
//    轮播图
    NewUiscrollerView *lunbo = [[NewUiscrollerView alloc] initWithFrame:CGRectMake(0, 60, self.view.bounds.size.width, 200) witharray:[NSArray arrayWithObjects:@"10.jpg", @"11.jpg", @"12.jpg", nil]];
    [self.view addSubview:lunbo];
    [lunbo release];
//    tableview
    [self.view addSubview:self.tableview];
    [_tableview release];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        NewTableViewCell *cell = [[NewTableViewCell alloc] init];
        return cell;
    } else {
    TwoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TwoTableViewCell"];
            ZhongModel *a = _bigmodel.datasouce;
            NSArray *b = a.listq;
            XiaoModel *x = b[indexPath.row];
    cell.imageview.image = [UIImage imageNamed:@"10.jpg"];
    cell.text1.text = x.title;
    return cell;
    }
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSLog(@"%ld", _bigmodel.datasouce.listq.count);
    return _bigmodel.datasouce.listq.count;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return CGFLOAT_MIN;
}
//返回每行高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 130;
}
//tableview懒加载
-(UITableView *)tableview {
    if (!_tableview) {
        self.tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 250, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStyleGrouped];
        [_tableview registerClass:[TwoTableViewCell class] forCellReuseIdentifier:@"TwoTableViewCell"];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        [_tableview release];
    }
    return _tableview;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
